<template>
    <div class="default-table-detail-container">
        <BaseTableInfo v-model="baseTableInfoModel" />
    </div>
</template>

<script lang="tsx" setup>

import StoreInfoApi from '~/src/api/webPath/StoreInfoApi';
import StoreInfoDetailApi from '/@/api/webPath/StoreInfoDetailApi.ts';

const props = defineProps({
    modelValue: {

    }
})
const route = useRouter()

const baseTableInfoModel = ref({
    columnCount: 3,
    autoFit: false,
    columnWidth: '300px',
    labelWidth: '100px',
    title: '基本信息',
    modelData: {},
    itemList: [
        {
            title: '',
            items: [   //渲染样式区域  通过key ===model 中的值
                //                                   {
                // label: "id",
                //                               field: "id",
                //                         },
                {
                    label: "仓库",
                    field: "storeId",
                    async render({ row }) {
                        const data = (await StoreInfoApi.getPageData()).data
                        console.log("data:", data)
                        console.log("current storeId", typeof row["storeId"])
                        const store = data.records.some(x => {
                            console.log("storeId:", typeof x.id, x.id, typeof row["storeId"], row["storeId"])
                            console.log("x.id == row['storeId']", +x.id == row["storeId"])
                            const result = (x.id.toString() === row["storeId"].toString())
                            console.log("compare result", result)
                            return result
                        })
                        console.log("store", store)
                        return <span>{store["storeName"]}</span>
                    }
                },
                {
                    label: "物料编号",
                    field: "materialCode",
                },
                {
                    label: "物料名称",
                    field: "materialName",
                },
                {
                    label: "物料规格",
                    field: "materialSpc",
                },
                // {
                //     label: "大类",
                //     field: "largeCategory",
                // },
                // {
                //     label: "中类",
                //     field: "middleCategory",
                // },
                {
                    label: "物料类别",
                    field: "smallCategory",
                },
                // {
                //     label: "存储条件",
                //     field: "storageCondition",
                // },
                // {
                //     label: "存储地点",
                //     field: "storagePlace",
                // },
                // {
                //     label: "检测项目",
                //     field: "testItems",
                // },
                {
                    label: "库存量",
                    field: "num",
                },
                // {
                //     label: "保留字段",
                //     field: "reserveOne",
                // },
                // {
                //     label: "保留字段",
                //     field: "reserveTwo",
                // },
                // {
                //     label: "保留字段",
                //     field: "reserveThree",
                // },
                // {
                //     label: "保留字段",
                //     field: "reserveFour",
                // },
                // {
                //     label: "保留字段",
                //     field: "reserveFive",
                // },
                // {
                //     label: "排序",
                //     field: "sort",
                // },
                {
                    label: "创建时间",
                    field: "create_time",
                },
                {
                    label: "更新时间",
                    field: "update_time",
                },
            ]
        }
    ],
    buttons: [   //标题操作区域
        // {
        //   name: "更多",
        //  buttonClass: 'danger',
        // width: 100,
        // click: (any: object) => {   //暴露的方法钩子
        // $baseMessage("这里执行业务", 'success', 'vab-hey-message-success');
        //},
        //},


    ]
})

onMounted(async () => {
    //初始化数据model
    const { data } = await StoreInfoDetailApi.getDetail({
        storeInfoDetailId: props.modelValue.query.storeInfoDetailId   //从路由中获取参数
    })
    baseTableInfoModel.value.modelData = data;





})
</script>

<style lang="scss" scoped>
.default-table-detail-container {
    :deep() {
        .el-form--inline {
            .el-form-item {
                margin-right: 10px;
            }
        }

        .el-descriptions__label {
            min-width: 80px !important;
            text-align: right;
        }
    }
}
</style>
